
/** Function 1 等价 Function 2*/
// var filter = function(f) {

// }

//filter() 过滤方法，过滤出符合条件的东西，再返回这个新数组

var arr_1 = ["ff", "wc", "we", "we"];
function filter() {
    var new_arr = [];
    for (var index in arr_1) {
        if (result(arr_1[index])) {
            new_arr.push(arr_1[index]);
        }
    }
};



var result = function (b) {
    if (b.includes("w")) {
        return true;
    } else {
        return false;
    }
}



/** Function 2 */
var arr = ["ab", "bc", "cd"];

/// fun = fun1 
function filter(fun) {
    newArr = []
    for (var index in arr) {
        if (fun(arr[index])) {
            newArr.push(arr[index])
        }
    }
    return newArr;
}

var fun1 = function (a) {
    if (a.includes("c")) {
        return true
    } else {
        return false;
    }
}

var fun2 = fun1;

var fun3 = function () {

};


console.log(filter(fun1));
filter(fun3)





/************************* */

var compare = function (a, b) {
    a = 10;
    b = 15;
    console.log(a, b);
}

var x = 2;
var y = 3;
compare(x, y);
console.log(x, y)

/************************* */

var cp = function (arr) {
    arr = clone(arr)
    arr[0] = 9;
}
var xx = [1, 2, 3]
cp(xx)
console.log(xx)

